package com.wealth.scsj.b_app.presenter;

import android.util.Log;

import com.wealth.scsj.b_app.base.UpdateUserProfilePictureBase;
import com.wealth.scsj.b_app.bean.UpdateUserProfilePictureBean;
import com.wealth.scsj.b_app.model.UpdateUserProfilePictureModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * 修改头像
 */

public class UpdateUserProfilePicturePresenter extends BasePresenter implements UpdateUserProfilePictureBase.IPresenter {

    private UpdateUserProfilePictureBase.IModel mModel;
    private UpdateUserProfilePictureBase.IView mView;

    public UpdateUserProfilePicturePresenter(UpdateUserProfilePictureBase.IView view) {
        mView = view;
        mModel = new UpdateUserProfilePictureModel();
    }
    @Override
    public void deliverUpdateUserProfilePictureData(RequestBody requestBody) {
        addSubscription(mModel.getUpdateUserProfilePictureData(requestBody, new ResponseCallback<UpdateUserProfilePictureBean>() {
            @Override
            public void onSuccess(UpdateUserProfilePictureBean result) {
                if (result.getStatusCode() == 200) {
                    mView.showSuccessMsg("店铺头像修改成功", result);
                } else {
                    mView.showErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("店铺头像修改失败", msg + "");
            }
        }));
    }
}
